<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta content="telephone=no" name="format-detection" />
    <!-- 留作将来统一添加 -->
    <TEMPLATE>${TEMPLATE}</TEMPLATE>
    <title>模板html</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
    <style type="text/css">
        body {
            background: rgba(90, 194, 255, 1);
        }

        .m-header-mod {
            z-index: 999;
            position: fixed;
            top: 0;
            width: 100%;
            height: 44px;
            box-sizing: content-box;
            background: rgba(90, 194, 255, 1);
        }

        header {
            height: 44px;
            box-sizing: content-box;
        }

        .c-header-back {
            position: absolute;
            left: 0;
            bottom: 0;
            width: 44px;
            height: 44px;
        }

        .c-header-nav {
            position: relative;
            width: 90px;
            font-size: 15px;
            font-weight: 500;
            color: rgba(255, 255, 255, 0.8);
            text-align: center;
            overflow: visible;
        }

        .c-header-nav-dot::before {
            content: "";
            position: absolute;
            bottom: 11px;
            right: 7px;
            width: 9px;
            height: 9px;
            background: rgba(226, 83, 83, 1);
            border-radius: 50%;
        }

        .c-header-nav-active {
            font-size: 16px;
            font-weight: 500;
            color: rgba(255, 255, 255, 1);
        }

        .c-header-nav-active::after {
            content: "";
            position: absolute;
            bottom: -7px;
            left: 50%;
            transform: translateX(-50%);
            width: 30px;
            height: 3px;
            background: rgba(255, 255, 255, 1);
            border-radius: 2px;
        }

        .container {
            padding: 20px 0;
        }

        .m-time-mod {
            margin-bottom: 15px;
        }

        .c-time-content {
            font-size: 13px;
            font-weight: 400;
            color: rgba(255, 255, 255, 1);
        }

        .m-order-mod {
            position: relative;
            padding: 20px 15px;
            margin: 15px;
            background: rgba(255, 255, 255, 1);
            box-shadow: 0px 4px 10px 0px rgba(0, 135, 214, 0.37);
            border-radius: 10px;
        }

        .c-order-state {
            font-size: 18px;
            font-weight: bold;
            color: rgba(25, 25, 25, 1);
        }

        .c-order-id {
            font-size: 13px;
            font-weight: 400;
            color: rgba(128, 128, 128, 1);
            margin-top: 12px;
        }

        .m-info-dot {
            position: relative;
        }

        .m-info-dot::after {
            content: "";
            position: absolute;
            right: 10px;
            top: 10px;
            width: 9px;
            height: 9px;
            background: rgba(226, 83, 83, 1);
            border-radius: 50%;
        }

        .m-info-mod {
            position: relative;
            margin: 15px;
            padding: 0 15px 10px 15px;
            background: rgba(255, 255, 255, 1);
            box-shadow: 0px 4px 10px 0px rgba(0, 135, 214, 0.37);
            border-radius: 10px;
        }

        .c-info-title {
            position: relative;
            height: 35px;
            font-size: 15px;
            font-weight: 400;
            color: rgba(90, 90, 90, 1);
        }

        .c-info-title::after {
            content: "";
            position: absolute;
            left: 0;
            bottom: 0;
            width: 100%;
            height: 1px;
            background: rgb(231, 230, 230);
            transform: scaleY(0.5);
        }

        .c-info-content {
            margin-top: 10px;
            font-size: 16px;
            font-weight: bold;
            color: rgba(25, 25, 25, 1);
            line-height: 26px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
        }

        .long-box {
            position: absolute;
            top: -42px;
            left: 50%;
            transform: translateX(-50%);
            width: 120px;
            height: 42px;
        }

        .long-box img {
            position: absolute;
            bottom: 0;
            left: 50%;
            width: 14px;
            height: 7px;
            transform: translateX(-50%);
        }

        .long-btn {
            border-radius: 6px;
        }

        .long-btn p {
            position: relative;
            background-color: rgba(35, 35, 35, 0.91);
            color: #fff;
            text-align: center;
            font-size: 12px;
            line-height: 35px;
            height: 35px;
            font-weight: 100;
            width: 60px;
        }

        .long-btn p.right::before {
            content: ' ';
            position: absolute;
            top: 50%;
            left: 0;
            height: 24px;
            background-color: #fff;
            width: 1px;
            transform: scaleX(0.5) translateY(-50%);
        }
    </style>
</head>

<body>
    <div class="vueApp" v-cloak>
        <header class="m-header-mod" data-flex="main:center cross:center">
            <img class="c-header-back" onclick="backToPrev()" src="../../image/ui/back.png" alt="">
            <div class="c-header-nav" v-bind:class="{'c-header-nav-active': navIndex === 0,'c-header-nav-dot': !orderIsAllView
            }" onclick="toggleNav(0)" style="margin-right: 11px;">订单消息</div>
            <div class="c-header-nav" v-bind:class="{'c-header-nav-active': navIndex === 1,'c-header-nav-dot': !systemIsAllView
            }" onclick="toggleNav(1)">系统消息</div>
        </header>
        <header></header>
        <div class="container" v-show="navIndex === 0">
            <div v-for="item,index in orderInfoGroup">
                <div class="m-time-mod" v-if="item.time" data-flex="main:center cross:center">
                    <div class="c-time-content">
                        {{item.time}}
                    </div>
                </div>
                <div class="m-order-mod" :class="{'m-info-dot': !item.view}" @click="viewOrderInfo(item)"
                    :data-index="index" ontouchstart="gtouchstart(this)" ontouchmove="gtouchmove()"
                    ontouchend="gtouchend()">
                    <div class="c-order-state">{{item.stateText}}</div>
                    <div class="c-order-id">订单号:{{item.orderNum}}</div>
                    <div v-if="item.sel" class="long-box">
                        <div class="long-btn" data-flex="">
                            <p>已读</p>
                            <p class="right">删除</p>
                        </div>
                        <img src="../../image/course/longpress.png" alt="">
                    </div>
                </div>
            </div>
        </div>
        <div class="container" v-show="navIndex === 1">
            <div v-for="item,index in systemInfoGroup">
                <div class="m-time-mod" v-if="item.time" data-flex="main:center cross:center">
                    <div class="c-time-content">
                        {{item.time}}
                    </div>
                </div>
                <div class="m-info-mod" :class="{'m-info-dot': !item.view}" @click="viewSystemInfo(item)"
                    :data-index="index" ontouchstart="gtouchstart(this)" ontouchmove="gtouchmove()"
                    ontouchend="gtouchend()">
                    <div class="c-info-title" data-flex="cross:center">系统推送消息</div>
                    <div class="c-info-content">{{ item.title }}</div>
                    <div v-if="item.sel" class="long-box">
                        <div class="long-btn" data-flex="">
                            <p>已读</p>
                            <p class="right">删除</p>
                        </div>
                        <img src="../../image/course/longpress.png" alt="">
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-logic.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript">
    // html 的引号一律为双引号(""),js 为单引号('')
    var USER, $S, vm;
    apiready = function () {
        $S = SERVICE();
        USER = USER();
        console.log(JSON.stringify(api.pageParam) + '=====pageParam');
        fnInit();
    };

    // 初始化
    function fnInit() {
        vm = new Vue({
            el: '.vueApp',
            data: {
                navIndex: 0,
                orderInfoGroup: [],
                systemInfoGroup: []
            },
            computed: {
                orderIsAllView: function () {
                    return this.orderInfoGroup.every(function (item) {
                        return item.view === true;
                    })
                },
                systemIsAllView: function () {
                    return this.systemInfoGroup.every(function (item) {
                        return item.view === true;
                    })
                }
            }
        });
        getOrderInfoGroup();
        getSystemInfoGroup();
    }

    // 获取订单消息数据
    function getOrderInfoGroup() {
        var url = '';
        var params = {};
        var callback = function (data) {
            vm.orderInfoGroup = [
                {
                    stateText: '订单已发货',
                    orderNum: 11142422211,
                    view: true,
                    time: '中午 12:23'
                },
                {
                    stateText: '售后申请已通过',
                    orderNum: 11142422211,
                    view: true,
                    time: '昨天 15:23'
                }
            ]
            // if (vm.pageNo == '1') {
            //     vm.tabs = [];
            // }
            // var listData = data.listData;
            // for (var i = 0; i < listData.length; i++) {
            //     var item = listData[i];

            // }
            // vm.listData = vm.listData.concat(data.listData);
            // status 为200时,只返回data
        };
        var error = function (res) {
            // status 不是200时,全部返回
            api.refreshHeaderLoadDone();
        };
        POST(url, params, callback, error);
    }

    function getSystemInfoGroup() {
        var url = '';
        var params = {};
        var callback = function (data) {
            vm.systemInfoGroup = [
                {
                    view: false,
                    time: '中午 12:23',
                    title: '这是系统推送消息的标题'
                },
                {
                    view: true,
                    title: '这是系统推送消息的内容',
                    time: '昨天 15:23'
                }
            ]
            // if (vm.pageNo == '1') {
            //     vm.tabs = [];
            // }
            // var listData = data.listData;
            // for (var i = 0; i < listData.length; i++) {
            //     var item = listData[i];

            // }
            // vm.listData = vm.listData.concat(data.listData);
            // status 为200时,只返回data
        }; 
         var error = function (res) {
            // status 不是200时,全部返回
            api.refreshHeaderLoadDone();
        };
        POST(url, params, callback, error);

    }

    function viewOrderInfo() {
        fnOpenPublicWin('订单详情', 'teacher/order_detail',)
    }

    function viewSystemInfo() {
        fnOpenPublicWin('消息详情', 'teacher/info_detail');
    }

    function toggleNav(arg) {
        vm.navIndex = arg;
    }

    function backToPrev() {
        fnDelayCloseWin();
    }

    var timeOutEvent = 0; //定时器
    var longIndex = -1;
    //开始按
    function gtouchstart(el) {
        timeOutEvent = setTimeout(function () {
            var list = vm.navIndex ? vm.systemInfoGroup : vm.orderInfoGroup;
            vm.listData = setPropertyInArray(list, 'sel', false);
            longIndex = el.dataset.index;
            longPress();
        }, 1000); //这里设置定时器，定义长按500毫秒触发长按事件，时间可以自己改，个人感觉500毫秒非常合适
        return false;
    };
    //手释放，如果在500毫秒内就释放，则取消长按事件，此时可以执行onclick应该执行的事件
    function gtouchend() {
        clearTimeout(timeOutEvent); //清除定时器
        if (timeOutEvent != 0) {
            //这里写要执行的内容（尤如onclick事件）
            // alert("你这是点击，不是长按");
        }
        return false;
    };
    //如果手指有移动，则取消所有事件，此时说明用户只是要移动而不是长按
    function gtouchmove() {
        clearTimeout(timeOutEvent); //清除定时器
        timeOutEvent = 0;
    };

    //真正长按后应该执行的内容
    function longPress() {
        timeOutEvent = 0;
        var list = vm.navIndex ? vm.systemInfoGroup : vm.orderInfoGroup,
            list = deepCopy(vm.listData);
        list[longIndex].sel = true;
        if (vm.navIndex) {
            vm.systemInfoGroup = list;
        } else {
            vm.orderInfoGroup = list;
        }
    }
</script>

</html>